#!/usr/bin/env python
# -*- coding: utf-8 -*-

from importall import lib
from concurrent.futures import ThreadPoolExecutor
import sys


def run(executor: ThreadPoolExecutor, cache_size: int = 8):
    for file in ('a', 'b', 'c', 'd'):  # ('a', 'b', 'c', 'd')
        data = 'data/fiu-meta/gsf-filesrv/gsf-filesrv.%s.csv' % (file)
        for algo in (0, 1, 3,):  # (0, 1, 3)
            args = '%d %s %d --DR=1 --PR=100 --PR2=250' % (algo, data, cache_size)  # --DR=1 --PR=100 --PR2=25
            out = 'output/gsf-filesrv.%s.%d/%d.txt' % (file, algo, cache_size)
            executor.submit(lib.cas_exec, 'scratch/fiu', args, out)
        # executor.submit(lib.cas_exec, 'scratch/opt', '4 %s %d' % (data, cache_size),
        #                 'output/gsf-filesrv.%s.4/%d.txt' % (file, cache_size))
    return


if __name__ == '__main__':
    with ThreadPoolExecutor(max_workers=4) as executor:
        cache_size = int(sys.argv[1]) if len(sys.argv) > 1 else 8
        run(executor, cache_size)
    print('gsf-filesrv finish')
